"""
Support module for logAnalyzer.py to join the output pdf's into one.

This module uses the pyPdf module to do it's work.
"""

import pyPdf
import os
 
def join(filename): 
	"""
	Main Join class. Joins the diferent pdf's into one and
	deletes the temporary pdf's
	"""
	fileList = ["output.pdf","trafic.pdf","statsresults.pdf"]
	output = pyPdf.PdfFileWriter()
	 
	for item in fileList:
		input1 = pyPdf.PdfFileReader(file(item, "rb"))
		for page in range(input1.getNumPages()):
			output.addPage(input1.getPage(page))
	 
	outputStream = file(filename, "wb")
	output.write(outputStream)
	outputStream.close()
	
	os.remove("statsresults.pdf")
	os.remove("trafic.pdf")
	os.remove("output.pdf")
